<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php $this->load->view('common/head');?>

<?php $this->load->view('common/header');?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar');?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs');?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set');?>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <form class="form-inline" action="" method="get">
                            <label class="inline">用户搜索</label>
                            <select name="field" class="form-control">
                                <option value="user">用户名</option>
                                <option value="phone">电话</option>
                            </select>
                            <input type="text" name="keyword" value="" class="form-control">
                            <label class="inline">&nbsp;&nbsp;排序：</label>
                            <select name="order" class="form-control">
                                <option  value="asc">注册时间升</option>
                                <option  value="desc">注册时间降</option>
                            </select>
                            <button type="submit" class="btn btn-purple btn-sm">
                                <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                                查询
                            </button>
                        </form>
                    </div>
                    <div class="col-xs-12" style="margin-top: 20px;">
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th>用户名</th>
                                <th>用户组</th>
                                <th>电话</th>
                                <th>紧急电话</th>
                                <th>积分</th>
                                <th class="center">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if(isset($users)){
                            foreach ($users as $key => $val) { ?>
                                <tr>
                                    <td><?php echo $val['user_name']; ?></td>
                                    <td class="grouptd">
                                        <span class="group" val="<?php echo $val['user_id']; ?>" <?php if($val['user_group']==3){echo 'style="color:red"';}?>><?php echo $val['title']; ?></span>
                                    </td>
                                    <td><?php echo $val['user_tel']; ?></td>
                                    <td><?php echo $val['user_urgent_tel']; ?></td>
                                    <td><?php echo $val['user_credit']; ?></td>
                                    <td class="center">
                                        <a href="<?php echo site_url(X_URL.'drivers/detail/'.$val['user_id']);?>">会员详细</a>&nbsp;
                                        <a class="audit_save" state="5" href="javascript:;" val="<?php echo site_url(X_URL.'drivers/audit_save');?>" user_id="<?php echo $val['user_id'];?>" >审核通过</a>&nbsp;
                                        <a class="audit_save" state="-1" href="javascript:;" val="<?php echo site_url(X_URL.'drivers/audit_save');?>" user_id="<?php echo $val['user_id'];?>" >审核拒绝</a>
                                    </td>
                                </tr>
                            <?php }}?>
                            </tbody>
                        </table>
                        <?php if($pagination){?><ul class="pagination"><?php echo $pagination;?></ul><?php }?>
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
    </div><!-- /.main-content -->

</div><?php $this->load->view('common/footer');?>


<?php $this->load->view('common/footerjs');?>
<!-- inline scripts related to this page -->
<script type="text/javascript">

    $(function () {
        $("#officialnews ul").html('<div class="ace-icon fa fa-spinner fa-spin orange"></div>');
    })
    $("#adduser").click(function () {
        window.location.href="add";
    });
     $(".audit_save").click(function () {
        var url = $(this).attr('val');
        var user_id = $(this).attr('user_id');
        var state = $(this).attr('state');
        if(state == 5){
            var title = "你确定通过该用户吗";
        }else{
            var title = "你确定拒绝该用户吗";
        }
        layer.confirm(title, {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.ajax({
                type : "post",
                url: url,
                data: {'user_id':user_id,'state':state,'csrf_test_name': ci_csrf_token()},
                dataType:"JSON",
                success: function (msg) {
                    if(msg.status==1){
                        layer.msg(msg.info, {
                            time: 1000, //1s后自动关闭
                            shade: 0.1,
                            icon: 1
                        },function () {
                            window.location.reload();
                        });
                    }else{
                        layer.msg(msg.info, {
                            time: 1000, //1s后自动关闭
                            shade: 0.1
                        });
                        return false;
                    }
                }
            })
        }, function(){});
    });

</script>
</body>
</html>
